﻿
function loadeJs(pathToJsFile, variableNameToCheck, callback) {
	if(typeof variableNameToCheck == 'string' && typeof window[variableNameToCheck] == "undefined") {
		var js = document.createElement("script");
		js.type = "text/javascript";
		js.src = pathToJsFile;
		document.body.appendChild(js);
		waitJsLoaded(variableNameToCheck, callback);
	} else {
		callback();
	}
}

function waitJsLoaded(variableNameToCheck, callback) {
	if(typeof variableNameToCheck == 'string' && typeof window[variableNameToCheck] == "undefined") {
		setTimeout(waitJsLoaded, 500, variableNameToCheck, callback);
	} else {
		callback();
	}
}